<template>
    <div>
        <ul class="mui-table-view">
            <li class="mui-table-view-cell mui-media" v-for="item in news" :key="item.id">
                <router-link :to="'/home/newsinfo/'+item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.imgUrl">
                    <div class="mui-media-body">
                        {{item.title}}
                        <p class='mui-ellipsis'>
                            <span>{{item.add_time |dateFormat() }}</span>
                            <span>点击: {{item.click}}次</span>
                        </p>
                    </div>
                </router-link>
            </li>
        </ul>
    </div>
</template>

<script>
import {Toast} from 'mint-ui'
export default {
    data() {
        return {
            news:[]
        }
    },
    methods:{
        getNews(){
            this.$http.get('static/data.json').then((response) =>{
                //console.log(response.body.data.newsList);
                if(response.body.ret){
                    this.news = response.body.data.newsList;
                }else{
                    Toast('加载失败')
                }

               
            })
        }
    },
    created(){
        this.getNews();
    }
}
</script>

<style scoped>
    .mui-ellipsis {
        font-size: 12px;
        color: #226aff;
        display: flex;
        justify-content: space-between;
    }
</style>